package ui.panel.transfers
{

	import beans.TowerBean;

	import flash.display.Bitmap;
	import flash.display.Sprite;
	import flash.filters.GlowFilter;

	import globals.ButtonType;
	import globals.Global;

	import ui.component.Label;
	import ui.component.StarRate;
	import ui.component.TextButton;

	import util.UIUtil;

	public class TowerInfo extends Sprite
	{

		private var nameLabel:Label;
		private var towerView:Bitmap;
		private var powerLabel:Label;
		private var speedLabel:Label;
		private var jobLabel:Label;
		private var damageStar:StarRate;
		private var intervalStar:StarRate;
		private var rangeStar:StarRate;
		private var nextALabel:Label;
		private var nextBLabel:Label;
		private var costLabel:Label;
		private var buildButton:TextButton;

		public function TowerInfo()
		{
			super();

			var bg:Bitmap = new Bitmap(Global.assetsManager.getAssetsAsBitmapData("tower_bg", "ui"));
			addChild(bg);

			nameLabel = new Label(14, 0xFFFFFF, true, "center");
			nameLabel.x = 64;
			nameLabel.y = 20;
			addChild(nameLabel);

			towerView = new Bitmap();
			towerView.filters = [new GlowFilter(0xFFFFFF, 1, 2, 2, 6)];
			addChild(towerView);

			var label:Label;
			label = new Label(12, 0xFFFFFF);
			label.x = 24;
			label.y = 160;
			label.text = "攻击：";
			addChild(label);

			powerLabel = new Label(12, 0xFFFFFF);
			powerLabel.x = 60;
			powerLabel.y = 160;
			powerLabel.text = "攻击：";
			addChild(powerLabel);

			label = new Label(12, 0xFFFFFF);
			label.x = 24;
			label.y = 176;
			label.text = "速度：";
			addChild(label);

			speedLabel = new Label(12, 0xFFFFFF);
			speedLabel.x = 60;
			speedLabel.y = 176;
			speedLabel.text = "速度：";
			addChild(speedLabel);

			label = new Label(12, 0xFFFFFF);
			label.x = 24;
			label.y = 192;
			label.text = "职业：";
			addChild(label);

			jobLabel = new Label(12, 0xFFFFFF);
			jobLabel.x = 60;
			jobLabel.y = 192;
			jobLabel.text = "职业：";
			addChild(jobLabel);

			label = new Label(12, 0xFFFFFF);
			label.x = 40;
			label.y = 216;
			label.text = "可改造为";
			addChild(label);

			nextALabel = new Label(12, 0xFFFFFF);
			nextALabel.x = 30;
			nextALabel.y = 240;
			addChild(nextALabel);

			nextBLabel = new Label(12, 0xFFFFFF);
			nextBLabel.x = 30;
			nextBLabel.y = 256;
			addChild(nextBLabel);

			costLabel = new Label(12, 0xFFFFFF);
			costLabel.x = 30;
			costLabel.y = 276;
			addChild(costLabel);

			buildButton = UIUtil.getTextButton(0, "建造", ButtonType.BUTTON_BLUE, buildHandler);
			buildButton.x = 50;
			buildButton.y = 300;
			addChild(buildButton);
		}

		public function update(bean:TowerBean):void
		{
			nameLabel.text = bean.name;
			towerView.bitmapData = Global.assetsManager.getAssetsAsBitmapData(bean.image);
			towerView.x = towerView.width * 0.5 + 4;
			towerView.y = towerView.height - 30;
			nextALabel.text = "2级炮塔";
			nextBLabel.text = "3级炮塔";
			costLabel.text = "消耗1111金币";
//			damageStar.update(bean.damage);
//			intervalStar.update(bean.interval);
//			rangeStar.update(bean.range);
		}

		private function buildHandler(button:TextButton):void
		{

		}

		public function clear():void
		{
			nameLabel.text = nextALabel.text = "";
			towerView.bitmapData = null;
			damageStar.clear();
			intervalStar.clear();
			rangeStar.clear();
		}
	}
}